<template>
     <el-dropdown @command="handleCommand">
        <span>
            <span class="loginNick">{{ userInfo.adminname }}</span>
            <i class="el-icon-setting" style="margin-right: 15px"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item :command="0">查看</el-dropdown-item>
            <el-dropdown-item :command="1">新增</el-dropdown-item>
            <el-dropdown-item :command="2">退出</el-dropdown-item>
        </el-dropdown-menu>
    </el-dropdown>
</template>

<script>
    import { mapState,mapActions } from 'vuex';
    export default {
        name:"HeaderView",
        computed:{
            ...mapState(["userInfo"])
        },
        methods:{
            ...mapActions(["exitAndUpdateAuthorityInfo"]),
            handleCommand(command) {
                // this.$alert(command);

                if (command == 2) { //点击退出
                    this.exitAndUpdateAuthorityInfo();
                    this.$router.push("/login")
                }
            }
        }
    }
</script>